<?php
require_once("../driver/tableLocation.php");
require_once("../driver/drive.php");
class classWHandle
{
    public function insert_class($array)
    {
        $tablename = tableLocation::classTable();
        $c = array();
        $v = array();
        foreach($array as $key=>$value)
        {
            array_push($c,$key);
            array_push($v,$value);
        }
        $csql = implode(",",$c);
        $vsql = implode("','",$v);
        $sql = "insert into $tablename($csql)values('$vsql')";
        $result = drive::exc($sql);
        return $result;
    }
    public function update_class($array, $id)
    {
        $sqlk=array();
        foreach($array as $key=>$value)
        {
            array_push($sqlk," `$key`='$value' ");
        }
        $sqls = implode(",",$sqlk);
        $table = tableLocation::classTable();
        $sql = "update $table set $sqls where id=$id";
        //echo $sql;
        return drive::exc($sql);
    }
    public function delete_class($id)
    {
        $table = tableLocation::classTable();
        $sql = "delete from $table where id=$id";
        return drive::exc($sql);
    }
}
?>